package com.guigu.www.erp.dengtao.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.guigu.www.erp.common.pojo.MDesignProcedure;
import com.guigu.www.erp.common.pojo.PageVo;
import com.guigu.www.erp.dengtao.dao.MDesignProcedureMapper;
import com.guigu.www.erp.dengtao.service.MDesignProcedureService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.Map;

@Service
@Transactional
public class MDesignProcedureServiceImpl implements MDesignProcedureService {
    @Autowired
    MDesignProcedureMapper mDesignProcedureMapper;
    @Override
    public void addgx(MDesignProcedure mDesignProcedure) {
        mDesignProcedureMapper.insert(mDesignProcedure);
    }

    @Override
    public String select() {
        return mDesignProcedureMapper.selectsyt();
    }

    @Override
    public PageVo<MDesignProcedure> findshcx(Map<String, String> map) {

        PageHelper.startPage(Integer.valueOf(map.get("pageNum")==null?1:Integer.valueOf(map.get("pageNum"))),
        Integer.valueOf(map.get("pageSize")==null?2:Integer.valueOf(map.get("pageSize"))));

        List<MDesignProcedure> mDesignProcedureList=mDesignProcedureMapper.selectPageAll();
        PageInfo<MDesignProcedure> ages=new PageInfo(mDesignProcedureList);
        long total = ages.getTotal();
        List<MDesignProcedure> list=ages.getList();

        return new PageVo<MDesignProcedure>(total,list);

    }

    @Override
    public PageVo<MDesignProcedure> sjdcxsy(Map<String, String> map) {

        PageHelper.startPage(Integer.valueOf(map.get("pageNum")==null?1:Integer.valueOf(map.get("pageNum"))),
                Integer.valueOf(map.get("pageSize")==null?2:Integer.valueOf(map.get("pageSize"))));
        String registerTime = map.get("registerTime");
        String checked = map.get("checker");
        List<MDesignProcedure> mDesignProcedureList=mDesignProcedureMapper.cxsy(registerTime,checked);
        PageInfo<MDesignProcedure> ages=new PageInfo(mDesignProcedureList);
        long total = ages.getTotal();
        List<MDesignProcedure> list=ages.getList();

        return new PageVo<MDesignProcedure>(total,list);    }


    @Override
    public void xiugai(String id,String sj) {
        mDesignProcedureMapper.xiugai(id,sj);
    }

    @Override
    public void xiugaibutguo(String id) {
        mDesignProcedureMapper.xiugaibutg(id);
    }

    @Override
    public PageVo<MDesignProcedure> bgsele(Map<String, String> map) {
        PageHelper.startPage(Integer.valueOf(map.get("pageNum")==null?1:Integer.valueOf(map.get("pageNum"))),
                Integer.valueOf(map.get("pageSize")==null?2:Integer.valueOf(map.get("pageSize"))));
        List<MDesignProcedure> mDesignProcedureList=mDesignProcedureMapper.bgbtg();
        PageInfo<MDesignProcedure> ages=new PageInfo(mDesignProcedureList);
        long total = ages.getTotal();
        List<MDesignProcedure> list=ages.getList();

        return new PageVo<MDesignProcedure>(total,list);    }

    @Override
    public void zongxiugai(MDesignProcedure mDesignProcedure) {
        mDesignProcedureMapper.zongxiugai(mDesignProcedure);
    }

    @Override
    public PageVo<MDesignProcedure> gxwlsjd(Map<String, String> map) {
        MDesignProcedure m=new MDesignProcedure();
        PageHelper.startPage(Integer.valueOf(map.get("pageNum")==null?1:Integer.valueOf(map.get("pageNum"))),
                Integer.valueOf(map.get("pageSize")==null?2:Integer.valueOf(map.get("pageSize"))));

        m.setRegisterTime(map.get("registerTime")==null?"":map.get("registerTime"));
        m.setChecker(map.get("checked")==null?"":map.get("checked"));

        List<MDesignProcedure> mDesignProcedureList=mDesignProcedureMapper.gxwlsjd(m);
        PageInfo<MDesignProcedure> ages=new PageInfo(mDesignProcedureList);
        long total = ages.getTotal();
        List<MDesignProcedure> list=ages.getList();

        return new PageVo<MDesignProcedure>(total,list);
    }

    @Override
    public void upt(MDesignProcedure mDesignProcedure) {
        mDesignProcedureMapper.updateByPrimaryKeySelective(mDesignProcedure);
    }

    @Override
    public PageVo<MDesignProcedure> gxwlsh(Map<String, String> map) {
        PageHelper.startPage(Integer.valueOf(map.get("pageNum")==null?1:Integer.valueOf(map.get("pageNum"))),
                Integer.valueOf(map.get("pageSize")==null?2:Integer.valueOf(map.get("pageSize"))));
        List<MDesignProcedure> mDesignProcedureList=mDesignProcedureMapper.wlsh();
        PageInfo<MDesignProcedure> ages=new PageInfo(mDesignProcedureList);
        long total = ages.getTotal();
        List<MDesignProcedure> list=ages.getList();

        return new PageVo<MDesignProcedure>(total,list);
    }

    @Override
    public void upttg(int parseInt) {
        mDesignProcedureMapper.up(parseInt);
    }

    @Override
    public void upbtg(int parseInt) {
        mDesignProcedureMapper.bup(parseInt);

    }

    @Override
    public PageVo<MDesignProcedure> sjdbg(Map<String, String> map) {
        PageHelper.startPage(Integer.valueOf(map.get("pageNum")==null?1:Integer.valueOf(map.get("pageNum"))),
                Integer.valueOf(map.get("pageSize")==null?2:Integer.valueOf(map.get("pageSize"))));
        List<MDesignProcedure> mDesignProcedureList=mDesignProcedureMapper.sjdbg();
        PageInfo<MDesignProcedure> ages=new PageInfo(mDesignProcedureList);
        long total = ages.getTotal();
        List<MDesignProcedure> list=ages.getList();

        return new PageVo<MDesignProcedure>(total,list);    }

    @Override
    public void xg(String id) {
        mDesignProcedureMapper.xg(Integer.parseInt(id));
    }

    @Override
    public MDesignProcedure cxyg(String id) {
        return mDesignProcedureMapper.selectByPrimaryKey(Integer.parseInt(id));
    }

    @Override
    public MDesignProcedure cxck(int id) {
        return  mDesignProcedureMapper.selectByPrimaryKey(id);
    }
}
